home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / doom / hxtutor.zip / HXTUTOR.DOC < prev    next >
Text File  |  1996-07-09  |  15KB  |  388 lines

  1.  
  2.                            Hexen Script Tutorial
  3.                                version .7
  4.                Authors: Chris White(cwhite@colorado.net)
  5.  
  6.  
  7. This file should contain the following files:
  8. HXTUTOR.WAD  - The 4 level Pwad file
  9. HXTUTOR.DOC  - The Manual, this file
  10. HXTUTO01.ACS - The fully commented Script File for Level 1
  11. HXTUTO02.ACS - The fully commented Script File for Level 2     
  12. HXTUTO03.ACS - The fully commented Script File for Level 3
  13. APP_A.TXT    - The Appendix with lists of TID's, SECTOR TAG's and LINE ID's
  14. HXTUTOR.TXT  - The text description file in Wad Template format
  15.  
  16. All of these(except the Wad file and HXTUTOR.TXT) should be printed out, so
  17. that you can follow along as the level progresses.
  18. You should also have a copy of the HEXEN SPECS by Ben Morris, version 0.9 is
  19. the latest as of this writing.
  20.  
  21.  
  22. Although this file was originally intended to be a Script Tutorial(and it
  23. still is), I have included other tricks that I thought might need some
  24. explaining.  Why did I create this?  There are Not enough Good Hexen levels
  25. out there, I believe it is the Scripts that are scarring people away from
  26. Hexen editing.  Also, I think learning to edit and program Hexen will prepare
  27. myself and others for editing the game we are all waiting for, QUAKE!!  In
  28. fact, QUAKE will have it's own C language.  All of you Doom editors that
  29. refuse to play with Hexen for one reason or another will be behind the people
  30. who have mastered and learned to program Hexen, when Quake does arrive.
  31.  
  32.  
  33.  
  34. Scripting Basics
  35.  
  36. The basic sript structure consists of two types OPEN and CALLED
  37.  
  38. OPEN scripts do not take arguments, they are Mainly used for things such as
  39.  Ambient Sounds(crickets, birds, katydids, gongs etc.) and for the Random
  40.  Spawning of Ettins and other monsters.  They are also used to check if
  41.  Puzzles have been completed yet.
  42.  
  43. A Sample OPEN Script: (Taken from HEXEN MAP01)
  44.  
  45. script 253 OPEN
  46. {
  47.     delay(random(3, 7)*100);
  48.     thingsound(36, "Ambient6", 100);
  49.     restart;
  50. }
  51.  
  52. This script is OPEN, so it automatically starts when the Level starts.
  53. Lets examine it line by line:
  54.  
  55. delay(random(3, 7)*100);  This is the same as delay 300 or 400 or 500 or 600
  56.                           or 700.  Or dividing by 35 tics per second equals
  57.                           a delay of Roughly 9, 12, 15, 18 or 20 seconds.
  58.  
  59. thingsound(36, "Ambient6", 100); This plays the sound Ambient6 at all things
  60.                                  with TID of 36(Most likely just X_MapSpots)
  61.                                  and with a volume of 100(on a scale of 1-127)
  62.                                  Ambient6 is simply an Owl
  63.  
  64. restart;   Restart the Script
  65.  
  66. What does this Script do?
  67. - It waits for 8 to 20 seconds
  68. - Plays an owl sound(who who)
  69. - restarts
  70. - It waits for 8 to 20 seconds
  71. - Plays an owl sound(who who)
  72. - restarts
  73. - It waits for 8 to 20 seconds
  74. - Plays an owl sound(who who)
  75. - restarts
  76. - It waits for 8 to 20 seconds
  77. - Plays an owl sound(who who)
  78. - restarts
  79. - Etc.,Etc.,Etc.,Etc.,Etc.....
  80.  
  81. Lets examine another OPEN Script (Also taken from HEXEN MAP01)
  82.  
  83. script 255 OPEN
  84. {
  85.     int var0;
  86.  
  87.     delay(8400);
  88.     var0 = random(0, 1);
  89.     if(var0 ==1)
  90.     {
  91.         Thing_Spawn(255, T_ETTIN, 128);
  92.     }
  93.     var0 = random(0, 1);
  94.     if(var0 ==1)
  95.     {
  96.         Thing_Spawn(254, T_ETTIN, 196);
  97.     }
  98.     var0 = random(0, 1);
  99.     if(var0 ==1)
  100.     {
  101.         Thing_Spawn(253, T_ETTIN, 196);
  102.     }
  103.     var0 = random(0, 1);
  104.     if(var0 ==1)
  105.     {
  106.         Thing_Spawn(252, T_ETTIN, 0);
  107.     }
  108.     restart;
  109. }
  110.  
  111. Again, lets examine it Line by Line
  112.  
  113. int var0;  This just Declares a Variable var0.  This could be called WaitTime,
  114.             EttinWait, WaItaLiTtle, variableZero, v, v0 or Whatever YOU want
  115.             to call it!!
  116.  
  117. delay(8400);  Wait 8400/35 = 240 Seconds or 4 minutes
  118.  
  119. var0 = random(0, 1);  var0 equals either 0 or 1
  120.  
  121. if(var0 == 1)  if var0 equals 1, as opposed to 0(50% chance)
  122. {
  123.     Thing_Spawn(255, T_ETTIN, 128);  Spawns an Ettin at thing with TID 255
  124. }                                    (again just a X_MapSpot)
  125.                                      Angle = 128 or West 
  126.  
  127. The next 3 IF statements are the same as the above, they just have different
  128.  TID's and Angles
  129.  
  130. restart;  Restart the Script
  131.  
  132. What does this do?
  133. -It waits for 4 minutes
  134.   -Picks a Random Number(0 or 1  50% chance)
  135.   -If Random Number = 1(50%) Spawns an Ettin at TID 255's at angle 128(West)
  136.   -Picks a Random Number(0 or 1  50% chance)
  137.   -If Random Number = 1(50%) Spawns an Ettin at TID 254's at angle 196(~South)
  138.   -Picks a Random Number(0 or 1  50% chance)
  139.   -If Random Number = 1(50%) Spawns an Ettin at TID 253's at angle 196(~South)
  140.   -Picks a Random Number(0 or 1  50% chance)
  141.   -If Random Number = 1(50%) Spawns an Ettin at TID 252's at angle 0(East)
  142. -Restarts
  143. -Etc.,Etc.,Etc.,Etc.,Etc....
  144.  
  145.  
  146. CALLED Scripts May or May Not take Arguments.  Remember, OPEN Scripts Start
  147.  Automatically when the Level starts. CALLED Scripts are called from the
  148.  statement ACS_EXECUTE.  This can be when a Line is Crossed, Hit, Hit By
  149. Weapon, Crossed By Monster, Used, etc.. Or can be activated when a Thing is
  150. Destroyed.  Or called from within another Script.
  151.  
  152. A Sample Called Script with No Arguments
  153.  
  154. script 1 (void)
  155. {
  156.     print(s:"YOU'RE GETTING CLOSER);
  157. }
  158.  
  159. What does this do?
  160. It simply prints:    you're getting closer
  161. when the script is called
  162. How is it called?
  163. This script would most likely be called by crossing a linedef.
  164.   For example:
  165.     Say you are looking for a key to open a door, pick a line that is close to
  166.     the key.  When the player crosses the line, he sees this message and knows
  167.     that he is getting close to finding the key.
  168. You would give the line special ACS_Execute
  169. The lines arguments would be:
  170. 1   1   0   0   0
  171. |   |   |   |   |
  172. |   |   Not used as this script is (void) and takes No Arguments
  173. |   |
  174. |   Map, assuming this script is for MAP01
  175. |
  176. Script number 1
  177.  
  178. A Sample Called Script with Arguments (The Breaking Glass Windows
  179.                                        From HEXEN MAP01)
  180.  
  181. script 1 (int arg0, int ar1, int arg2)
  182.  
  183. Now lets stop for a second, this is how the decompiled script looks when
  184. decomplied using DEACC or similar utility.  What did this script look like
  185. before Raven compiled it?  Remember that the Variable Names cannot be
  186. retrieved when decompiling a Script, so they are just given names such as
  187. arg0, arg1, arg2 etc.  The original probably looked more like this:
  188.  
  189. script 1 ( SectorNum, SoundTID, GlassTID)
  190. {
  191.     int GlassCount;
  192.  
  193.     Floor_LowerInstant( SectorNum, 0, 16);
  194.     thingsound( SoundTID, "GlassShatter", 127);
  195.     delay(1);
  196.     GlassCount = 20;
  197.     while(GlassCount >0)
  198.     {
  199.         GlassCount--;
  200.         Thing_ProjectileGravity(SoundTID, random(54, 63), random(0, 255),
  201.                                 random(10, 40), random(5, 20));
  202.         Thing_ProjectileGravity(GlassTID, random(54, 63), random(0, 255),
  203.                                 random(10, 40), random(5, 20));
  204.     }
  205. }
  206.  
  207. Again lets examine it line by line
  208.  
  209. int GlassCount;  This just declares a variable to be used in the While
  210.                  loop.
  211.  
  212. Floor_LowerInstant( SectorNum, 0, 16);  This lowers the sector whose Tag =
  213.                                         SectorNum.  This function takes No
  214.                                         2nd argument, so it is 0.  16 is the
  215.                                         Height that it lowers in 8 pixel
  216.                                         units.  16*8 = 128 and we all know
  217.                                         how high that is.
  218.  
  219. thingsound( SoundTID, "GlassShatter", 127);  This plays the sound GlassShatter
  220.                                              at all things(X_MapSpots) with
  221.                                              a TID = Sound TID
  222. delay(1);   Waits for 1/35 of a second
  223.  
  224. GlassCount = 20;  Sets the Local Variable GlassCount to 20
  225.  
  226. while( GlassCount > 0); GlassCount = 20 right now
  227. {
  228.     GlassCount--;  Subtracts 1 from GlassCount
  229.     Thing_ProjectileGravity(SoundTID, random(54, 63), random(0, 25